/**
 * @a https://leetcode.cn/problems/contains-duplicate/
 */


#include "common.h"


class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        unordered_set<int> exists;
        for(auto num : nums){
            if(exists.count(num)) return true;
            exists.insert(num);
        }
        return false;
    }
};


class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        unordered_map<int,int> num_cnt;
        for(auto num: nums){
            int tmp = num_cnt[num]++;
            if(tmp == 1) return true;
        }
        return false;
    }
};